home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / midas060 / samples / midpnt / midpview.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-14  |  6.0 KB  |  215 lines

  1. /*
  2.  *      MidpView.cpp
  3.  *
  4.  * MIDAS Module Player for Windows NT View definitions
  5.  *
  6.  * Copyright 1996 Petteri Kangaslampi
  7. */
  8.  
  9. #define WIN32_LEAN_AND_MEAN
  10. #include <windows.h>
  11. #include "midasdll.h"
  12. #include "MidpNT.h"
  13. #include "MidpView.h"
  14.  
  15.  
  16. /****************************************************************************\
  17. *
  18. * Function:     midpView::midpView(void)
  19. *
  20. * Description:  MIDP View class constructor. Takes care of initialization
  21. *               common to all views.
  22. *
  23. \****************************************************************************/
  24.  
  25. midpView::midpView(void)
  26. {
  27. }
  28.  
  29.  
  30.  
  31.  
  32. /****************************************************************************\
  33. *
  34. * Function:     midpView::~midpView(void)
  35. *
  36. * Description:  MIDP View class destructor. Takes care of uninitialization
  37. *               common to all views.
  38. *
  39. \****************************************************************************/
  40.  
  41. midpView::~midpView(void)
  42. {
  43. }
  44.  
  45.  
  46.  
  47.  
  48. /****************************************************************************\
  49. *
  50. * Function:     midpViewWindow::midpViewWindow(int instanceNumber,
  51. *                   midpView *view, Registry *registry = NULL)
  52. *
  53. * Description:  MIDP View Window class constructor. Takes care of
  54. *               initialization common to all windows.
  55. *
  56. * Input:        int instanceNumber      view window class instance number
  57. *                                       (zero-based)
  58. *               midpView *view          pointer to owner view object
  59. *               Registry *registry      optional pointer to a Registry object
  60. *                                       where the window infomartion will be
  61. *                                       restored from.
  62. *
  63. \****************************************************************************/
  64.  
  65. midpViewWindow::midpViewWindow(int instanceNumber, midpView *view,
  66.     Registry *registry)
  67. {
  68.     ownerView = view;
  69.     instanceNumber = instanceNumber;    // bye-bye warning
  70.  
  71.     startX = startY = startWidth = startHeight = CW_USEDEFAULT;
  72.  
  73.     if ( registry != NULL )
  74.     {
  75.         if ( registry->ValueExists("X") )
  76.         {
  77.             startX = registry->ValueDWORD("X", 50);
  78.             startY = registry->ValueDWORD("Y", 50);
  79.             startWidth = registry->ValueDWORD("Width", 50);
  80.             startHeight = registry->ValueDWORD("Height", 50);
  81.         }
  82.     }
  83. }
  84.  
  85.  
  86.  
  87.  
  88. /****************************************************************************\
  89. *
  90. * Function:     midpViewWindow::~midpViewWindow(void)
  91. *
  92. * Description:  MIDP View Window class destructor. Takes care of
  93. *               uninitialization common to all windows.
  94. *
  95. \****************************************************************************/
  96.  
  97. midpViewWindow::~midpViewWindow(void)
  98. {
  99.     startX = startY = startWidth = startHeight = CW_USEDEFAULT;
  100. }
  101.  
  102.  
  103.  
  104. /****************************************************************************\
  105. *
  106. * Function:     HWND midpViewWindow::WindowHandle(void)
  107. *
  108. * Description:  Reads the window handle.
  109. *
  110. * Returns:      Window handle for the window
  111. *
  112. \****************************************************************************/
  113.  
  114. HWND midpViewWindow::WindowHandle(void)
  115. {
  116.     return hwnd;
  117. }
  118.  
  119.  
  120.  
  121.  
  122. /****************************************************************************\
  123. *
  124. * Function:     LRESULT midpViewWindow::SendWindowMessage(UINT message,
  125. *                   WPARAM wparam, LPARAM lparam);
  126. *
  127. * Description:  Sends a message to the window
  128. *
  129. * Returns:      Return value from SendMessage().
  130. *
  131. \****************************************************************************/
  132.  
  133. LRESULT midpViewWindow::SendWindowMessage(UINT message, WPARAM wparam,
  134.     LPARAM lparam)
  135. {
  136.     return SendMessage(hwnd, message, wparam, lparam);
  137. }
  138.  
  139.  
  140.  
  141.  
  142. /****************************************************************************\
  143. *
  144. * Function:     void midpViewWindow::SongChanged(void)
  145. *
  146. * Description:  Notify the window that song has been changed
  147. *
  148. \****************************************************************************/
  149.  
  150. void midpViewWindow::SongChanged(void)
  151. {
  152.     SendWindowMessage(MIDPMSG_SONGCHANGED, 0, 0);
  153. }
  154.  
  155.  
  156.  
  157.  
  158. /****************************************************************************\
  159. *
  160. * Function:     void midpViewWindow::Update(void)
  161. *
  162. * Description:  Instruct the window to update itself
  163. *
  164. \****************************************************************************/
  165.  
  166. void midpViewWindow::Update(void)
  167. {
  168. }
  169.  
  170.  
  171.  
  172. /****************************************************************************\
  173. *
  174. * Function:     void midpViewWindow::SaveState(Registry *registry)
  175. *
  176. * Description:  Saves the window's state to registry
  177. *
  178. * Input:        Registry *registry      Pointer to the Registry object where
  179. *                                       the state will be saved. The registry
  180. *                                       must be open at the correct key.
  181. *
  182. \****************************************************************************/
  183.  
  184. void midpViewWindow::SaveState(Registry *registry)
  185. {
  186.     RECT        rect;
  187.  
  188.     GetWindowRect(hwnd, &rect);
  189.     registry->WriteString("ViewClass", ownerView->Name());
  190.     registry->WriteDWORD("X", rect.left);
  191.     registry->WriteDWORD("Y", rect.top);
  192.     registry->WriteDWORD("Width", rect.right - rect.left);
  193.     registry->WriteDWORD("Height", rect.bottom - rect.top);
  194. }
  195.  
  196.  
  197.  
  198.  
  199. /****************************************************************************\
  200. *
  201. * Function:     void midpViewWindow::RestoreState(Registry *registry)
  202. *
  203. * Description:  Restores the window's state from registry
  204. *
  205. * Input:        Registry *registry      Pointer to the Registry object from
  206. *                                       which the state will be restored. The
  207. *                                       The registry must be open at the
  208. *                                       correct key.
  209. *
  210. \****************************************************************************/
  211.  
  212. void midpViewWindow::RestoreState(Registry *registry)
  213. {
  214.     registry = registry;
  215. }